import { call, put } from 'redux-saga/effects'
import { subjectsApi } from '../../../network'
import { UPDATE_PROJECTS } from '../../actions'

const getProjects = function * getProjects(action) {
  try {
    const subjects = yield call(subjectsApi.getprojects, action.payload)
    yield put({type: UPDATE_PROJECTS, payload: subjects})
  } catch(e) {
    return Promise.reject(e.message)
  }
}

export default getProjects